import { defineStore } from "pinia";
import { computed, ref } from "vue";

// 通过 defineStore 定义数据仓库，返回获取仓库的函数，命名一般是 useXXXStore
export const useCounterStore = defineStore("counter", () => {
  // states 数据
  const totalCount = ref(0);

  // 修改数据
  const addTotalCount = (value: number) => {
    totalCount.value += value;
  };
  const dobuleTotalCount = computed(()=>{
    return totalCount.value * 2
  })

  // 一定要记得返回数据
  return { totalCount, addTotalCount, dobuleTotalCount };
},{persist:true});
